//加载模块
layui.use(['layedit', 'upload', 'element', 'layer', 'form', 'table'], function () { //亦可加载特定模块：layui.use(['layer', 'laydate', function(){
    //得到各种内置组件
    var layer = layui.layer //弹层
        , form = layui.form
        , upload = layui.upload
        , element = layui.element;
    var layedit = layui.layedit;
    // layedit.build('content'); //建立编辑器
    layedit.set({
        uploadImage: {
            url: '/upload' //接口url
            , type: 'post' //默认post
        }
    });
    //注意：layedit.set 一定要放在 build 前面，否则配置全局接口将无效。
    var index = layedit.build('content'); //建立编辑器
});

$(function () {
    findById(sessionStorage.getItem("productId"))
})

function findById(id) {
    $.ajax({
        url: '/back/product/findByID',
        data: {id: id},
        type: 'get',
        dataType: 'json',
        success: function (data) {
            setUserData(data.data);
        }
    });
}

//赋值
function setUserData(data) {
    console.log(data);
    layui.use(['layedit', 'form'],
        function () {
            let form = layui.form;
            layedit.setContent(index, data.content);
            form.render();//重新渲染

        });

}